package enumerate_try;

public class Player {
    private Role role; // 玩家角色

    public Player(Role role) {
        this.role = role;
    }

    public void attack(Player target) {
        int damage = this.role.getAttack() - target.getRole().getDefense();
        if (damage > 0) {
            int newHp = target.getRole().getHp() - damage;
            target.getRole().setHp(newHp);
        }
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }
}
